/*
 * CSComFacadeMBean.java    0.0.1    23/set/2009
 * 
 * Copyright (c) 2009 mentalsmash.org
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 * The use of the Apache License does not indicate that this project is
 * affiliated with the Apache Software Foundation.
 */ 
package org.mentalsmash.tazio.net.cs.server;


/**
 * This MBean interface is intended to provide monitoring facilities
 * over the <i>Client-Server Communication Service</i> that resides server-side.
 * 
 * @version    0.0.1    23/set/2009    
 * @author     Andrea Reale <andrea.reale@gmail.com>
 */
public interface CSComFacadeMBean {

	/**
	 * Get the current port on which the Client-Server communication subsystem is listening on
	 * @return the current port on which the Client-Server communication subsystem is listening on
	 */
	int getPort();
	
	/**
	 * Change the port on which the Client-Server communication subsystem listens to incoming
	 * connections. 
	 * <p>
	 * <strong>BEWARE</strong>: This may require the subsystem to restart, and every active connection to be
	 * lost.
	 * </p>
	 * @param newPort
	 */
	void setPort(int newPort);
	
	/**
	 * Returns the string representation of the local address on which the Client-Server communication
	 * subsystem is listening on.
	 * @return the string representation of the local address on which the Client-Server communication
	 * 		   subsystem is listening on.
	 */
	String getHost();

	
	/**
	 * Returns the number of sockets connected to the service at the current time.
	 * @return the number of sockets connected to the service at the current time.
	 */
	int getNumConnections();
	
	/**
	 * The number of idle working threads ready to serve incoming requests
	 * @return The number of idle working threads ready to serve incoming requests
	 */
	int getNumIdleWorkingThreads();
	/**
	 * The number of active working threads, i.e. the threads that are currently serving
	 * requests
	 * @return The number of active working threads.
	 */
	int getNumActiveWorkingThreads();
	/**
	 * The number of direct buffers currently used by the service
	 * @return The number of direct buffers currently used by the service
	 */
	int getNumActiveBuffers();
	/**
	 * The number of direct buffers that are allocated in memory but currently idle.
	 * @return The number of direct buffers that are allocated in memory but currently idle.
	 */
	int getNumIdleBuffers();
	
	int getBufferSize();
	
	/**
	 * Checks whether the <i>Client-Server Communication Subsystem</i> is running.
	 * @return true if the <i>Client-Server Communication Subsystem</i> is running.
	 */
	boolean isRunning();
	
	/**
	 * Gets the fully qualified name of the  class that instantiates 
	 * {@link org.mentalsmash.tazio.net.cs.server.ProtocolHandler ProtocolHandler}s for the
	 * Communication subsystem.
	 * @return the fully qualified name of the  class that instantiates 
	 *         {@link org.mentalsmash.tazio.net.cs.server.ProtocolHandler ProtocolHandler}s
	 */
	String getProtocolHandlerClassName();
	
	/**
	 * Gets the number of currently requests served by the <i>CS Communication Subsystem</i>
	 * @return the number of currently requests served by the <i>CS Communication Subsystem</i>
	 */
	int getNumRequestsServed();
	/**
	 * Returns the value of the keepAliveMode Parameter.
	 * <p>
	 * If <i>KeepAliveMode</i> is ON, the <i>CS Com Subsystem</i> will try to restart itself
	 * when crashes occur. 
	 * </p>
	 * @return the value of the keepAliveMode Parameter.
	 */
	boolean isKeepAliveModeOn();
	
	/**
	 * Sets the value of the keepAliveMode Parameter.
	 * <p>
	 * Setting the <i>KeepAliveMode</i> to ON will make the <i>CS Com Subsystem</i> try to restart itself
	 * when crashes occur. 
	 * </p>
	 * @param keepAliveModeOn
	 */
	void setKeepAliveModeOn(boolean keepAliveModeOn);
	
	/**
	 * Returns true if the server is using gzip compression for its responses.
	 * @return true if the server is using gzip compression for its responses.
	 */
	boolean isUsingGzip();
}
